package cn.iocoder.yudao.module.scrm.strategy;

import cn.hutool.core.lang.Pair;
import cn.iocoder.yudao.module.scrm.enums.common.CrmBizTypeEnum;
import cn.iocoder.yudao.module.scrm.strategy.strategyimpl.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author LiZhiMin
 * @Date 2024/9/13 9:49
 */
@Component
public class DeleteStrategyFactory {

    private final Map<Pair<CrmBizTypeEnum, CrmBizTypeEnum>, DeleteStrategy> strategyFactory = new HashMap<>();

    @Autowired
    public DeleteStrategyFactory(List<DeleteStrategy> strategyList) {
        for (DeleteStrategy strategy : strategyList) {
            // 将处理器注册到工厂中（可以根据需要调整键的类型）
            if (strategy instanceof CustomerDeleteStrategyImpl) {
                strategyFactory.put(Pair.of(CrmBizTypeEnum.CRM_CUSTOMER, CrmBizTypeEnum.CRM_CUSTOMER_RELEVANT_DATA), strategy);
            }
        }
    }

    public DeleteStrategy getStrategy(CrmBizTypeEnum customer, CrmBizTypeEnum relevantData) {
        return strategyFactory.get(Pair.of(customer, relevantData));
    }
}
